package com.maiji.cloud.service;

import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.service.IService;
import com.maiji.cloud.entities.shopingmall.ShopingOrder;
import com.maiji.cloud.request.ReqMetaData;
import com.maiji.cloud.request.shopingmall.DbApplyExamineReqData;
import com.maiji.cloud.request.shopingmall.DbApplyInfoReqData;
import com.maiji.cloud.response.BaseMetaResDto;
import org.springframework.scheduling.annotation.Async;
import com.maiji.cloud.entities.shopingmall.DistributionAgentApplyEntity;
import com.maiji.cloud.entities.shopingmall.DistributionFundRuleEntity;
import com.maiji.cloud.request.BaseDataReqDto;
import com.maiji.cloud.request.shopingmall.DistributionLogListReqDto;
import com.maiji.cloud.request.shopingmall.SubmitApplayReqData;
import com.maiji.cloud.response.BaseDataResDto;
import com.maiji.cloud.response.BaseResDto;
import com.maiji.cloud.response.shopingmall.DistributionAgentApplyInfoResData;
import com.maiji.cloud.response.shopingmall.DistributionLogListResDto;

public interface DistributionService extends IService<DistributionAgentApplyEntity> {

	/**
	 * 用户申请分销代理
	 * 
	 * @param param
	 * @param maijiToken
	 * @return
	 */
	BaseResDto submitApplay(BaseDataReqDto<SubmitApplayReqData> param, String maijiToken);

	/**
	 * 获得分销总额
	 * 
	 * @param param
	 * @param maijiToken
	 * @return
	 */
	Double getDistributionSumMoney(DistributionLogListReqDto param, String maijiToken);

	/**
	 * 获得分校明细列表
	 * 
	 * @param maijiToken
	 * @return
	 */
	public DistributionLogListResDto getDistributionLogList(DistributionLogListReqDto param, String maijiToken);

    /**
	 * 异步给用户分发分销资金
	 * 
	 * @param shopingOrder
	 */
	@Async
	public void asyncDistributionFund(ShopingOrder shopingOrder);

	/**
	 * 订单退款完成扣除订单产生的分销基金
	 * @param orderId
	 */
	@Async
	public void asyncReturnDistributionFund(String orderId);

	/**
	 * 获取一、二级用户的分销比例
	 * @return
	 */
	public BaseDataResDto<List<DistributionFundRuleEntity>> getCommissionRate();

	public BaseDataResDto<DistributionAgentApplyInfoResData> getDistributionAgentApplyInfo(String maijiToken);

    BaseMetaResDto<List<DistributionAgentApplyInfoResData>> findAllDbApplyInfos(DbApplyInfoReqData data, ReqMetaData metaData);

    BaseResDto examineDbApply(DbApplyExamineReqData data);

    BaseDataResDto<Map<String, Double>> findDistributionCapitalCount();
}
